home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE13 / TIPTRIX / LISTING4.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-08-20  |  772 b   |  17 lines

  1. procedure TForm1.MyGridDrawCell(Sender: TObject; Col, Row: Longint;
  2.                                 Rect: TRect; State: TGridDrawState);
  3.   var
  4.     TextStr : array[0..255] of Char;
  5. begin
  6.   {Because DefaultDrawing is set to True, the cell will actually be drawn once,
  7.    so call FillRect to blank it out. This may seem like more work, but in fact
  8.    everything like setting the font, pen and brushes is set this way, so all
  9.    the text drawing is simpler as none of this behaviour needs to be reproduced
  10.    here.}
  11.   MyGrid.Canvas.FillRect(Rect);
  12.   StrPCopy(TextStr,MyGrid.Cells[Col,Row]);
  13.   Rect.Top := Rect.Top + 2;  {Adjust for looks}
  14.   DrawText(MyGrid.Canvas.Handle,TextStr,StrLen(TextStr),Rect,
  15.            DT_CENTER or DT_NOPREFIX or DT_WORDBREAK);
  16. end;
  17.